package com.tsing.wms.vo.req;

import com.tsing.wms.valid.AddGroup;
import com.tsing.wms.valid.UpdateGroup;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.*;

/**
 * @author TheTsing
 * @create 2022-04-13 21:17
 */
@Data
public class UserReqVO {

    @Null(message = "新增时不能传入id", groups = {AddGroup.class})
    @NotBlank(message = "id不能为空", groups = {UpdateGroup.class})
    private String id;

    @ApiModelProperty("用户名")
    @NotBlank(message = "用户名不能为空", groups = {AddGroup.class})
    private String username;

    @ApiModelProperty("联系电话")
    @NotBlank(message = "联系电话不能为空", groups = {AddGroup.class})
    @Pattern(regexp = "^(13[0-9]|14[5|7]|15[0|1|2|3|4|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\\d{8}$", message = "手机号格式不合法", groups = {AddGroup.class, UpdateGroup.class})
    private String phone;

    @ApiModelProperty("电子邮箱")
    @NotBlank(message = "电子邮箱不能为空", groups = {AddGroup.class})
    @Email(message = "邮箱格式不合法", groups = {AddGroup.class, UpdateGroup.class})
    private String email;

    @ApiModelProperty("身份  1 管理员   2 供应商")
    @NotNull(message = "身份不能为空", groups = {AddGroup.class})
    @Range(min = 1, max = 2, message = "只能传入1或者2，1 管理员   2 供应商", groups = {AddGroup.class, UpdateGroup.class})
    private Integer identity;

    @ApiModelProperty("描述")
    private String description;

}
